package com.hm.search.controller;
import com.hm.search.pojo.ItemDoc;
import com.hm.search.pojo.RequestParams;
import com.hm.search.service.SearchService;
import com.hmall.common.dto.PageDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RequestMapping("/search")
@RestController
public class SearchController {
    @Autowired
    private SearchService hmservice;
    @GetMapping("/suggestion")
    public List<String> Suggestion(@RequestParam("key") String prefix){
        return hmservice.getSuggestions(prefix);
    }





    @PostMapping("/filters")
    public Map<String,List<String>> getFilters(@RequestBody RequestParams params){
        return hmservice.getFilters(params);
    }




    @PostMapping("/list")
    public PageDTO<ItemDoc>  List(@RequestBody RequestParams requestParam){
        return hmservice.list(requestParam);
    }

}
